Add failing test case for constructor + readonly + list + constructor_arguments#240
Add failing test case for constructor + readonly + list + constructor_arguments#240
Conversation
|
It's an intended behavior, see https://automapper.jolicode.com/latest/getting-started/configuration/ on Adding #[Mapper(constructorStrategy: ConstructorStrategy::ALWAYS)]on top of class make the test work By default, if all properties from the source are not present on the target constructor we build the class without invoking the constructor Otherwise we generate it, this parameter force the generation of the constructor. Maybe we could always generate it and use this behavior depending on a context value instead ? |
I think this could confusion with the parameter That's being said, I understand what you explained. I do think this should be clarified in the documentation.
I was thinking that indeed. But actually, automapper will never be able to construct my target based on the source. So I'll always need to repeat the context option. So now, I don't think it's useful anymore. TL;DR: It may be only a doc issue. |
Basically we would generate both possibility of construction and if constructor arguments is present for this class we use the constructor (otherwise we don't) Think it will work better. The constructor strategy would still be present and would determine what's the default behavior when constructor arguments are not present in the context :
|
|
It's up to you, but what is sure is I don't need this feature |
Could be useful if there is code that can give those constructor arguments and other that cannot for the same mapping |
|
I'm closing this, don't have the time to do that and even if the feature can be useful, i never needed it. |
No description provided.